local iori_attack = class('iori_attack',function()
	return display.newNode()
end)

function iori_attack:ctor()
	self:pos(display.cx+400,display.cy)
	display.newSolidCircle(8,{color = cc.c4f(1.0,0,1.0,0.8)}):addTo(self)
	local frames = display.newFrames("iori_ack_%03d.png", 0, 15)
	local frames2 = display.newFrames("iori_ack_b_%02d.png", 1, 10)

	self.iori = cc.Sprite:createWithSpriteFrame(frames[1]):addTo(self)
	self.iori:setFlippedX(true)
	local w = self.iori:getContentSize().width + 20
	--self.iori:runAction(cc.RepeatForever:create(cc.Animate:create(display.newAnimation(frames, 1.2/#frames))))
	self.iori:setAnchorPoint(cc.p(0,0))

	--self.ack = cc.Sprite:createWithSpriteFrame(frames2[1]):addTo(self)
	--self.ack:runAction(cc.RepeatForever:create(cc.Animate:create(display.newAnimation(frames2, 1.2/#frames))))
	--self.ack:setAnchorPoint(cc.p(0.5,0))
	--self.ack:pos(w,0)


	local add_ack_seq = cc.Sequence:create(
		cc.DelayTime:create(1.2/#frames*3),
		cc.CallFunc:create(function()
			local ex = cc.ParticleSystemQuad:create('ack.plist')
			--ex:pos(100,100)
			local tmp = cc.Sprite:createWithSpriteFrame(frames2[1])
			--local tmp = cc.Sprite:create()
			tmp:addChild(ex)
			tmp:runAction(cc.RepeatForever:create(cc.Animate:create(display.newAnimation(frames2, 1.2/#frames))))
			tmp:setAnchorPoint(cc.p(0.5,0))
			tmp:pos(0,-37)
			--[[
			tmp:runAction(cc.Sequence:create(
					cc.MoveBy:create(3,cc.p(display.width,0)),
					cc.RemoveSelf:create()
				)
			)
			]]
			local tmpBody = cc.PhysicsBody:createBox(cc.size(78,74))
			
			local node = display.newNode():addTo(self)
			node:setAnchorPoint(cc.p(0.5,0.5))
			node:setPhysicsBody(tmpBody)
			node:pos(-w/2,37)
			node:addChild(tmp)
			tmpBody:setVelocity(cc.p(-500,0))
			tmpBody:setContactTestBitmask(-1)
			tmpBody:setMass(500)
			end)

		)
	self.spawn = cc.Spawn:create({cc.Animate:create(display.newAnimation(frames, 1.2/#frames)),add_ack_seq})
	self.iori:runAction(cc.RepeatForever:create(self.spawn))
	--self.iori:runAction(self.spawn)



	--[[
	local spriteWidth = self.iori[1]:getContentSize().width
	local spriteHeight = self.iori[1]:getContentSize().height

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(84,122) ,cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-84)/2 - 100,(spriteHeight-122)/2 -8))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(86,116),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-86)/2 - 92,(spriteHeight-116)/2 - 10))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(80,82),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-80)/2 - 96,(spriteHeight-82)/2 - 42))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(80,112),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-80)/2 - 100,(spriteHeight-112)/2 - 16))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(80,118),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-80)/2 - 104,(spriteHeight-118)/2 - 8))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(86,118),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-86)/2 - 96,(spriteHeight-118)/2 - 10))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(82,82),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-82)/2 - 96,(spriteHeight-82)/2 - 45))

	self.body[#self.body+1] = cc.PhysicsBody:createBox(cc.size(78,114),cc.PHYSICSBODY_MATERIAL_DEFAULT , cc.p((spriteWidth-78)/2 - 104,(spriteHeight-114)/2 - 16))

	for i=1,8 do
		self.iori[i]:setPhysicsBody(self.body[i])
		self.body[i]:setContactTestBitmask(3)
		self.body[i]:setTag(130+i)
	end
	]]

	--self:runAction(cc.Animate:create(cc.FlipY:create(true)))

end

return iori_attack